<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
    //http://www.sucaihuo.com/modals/5/518/demo/ui_features.html
        $this->display();
    }
    public function checkLogin(){
       // session('flag',null);
       
        $admin=M('admin');
        $map   =   array();
        $map['admin_name']  = I('post.username');
        $map['password']    = I('post.password');
       
        $res=$admin->where($map)->select();
        if($res==null){
            $this->error('用户名密码错误');
        }else {
           $_SESSION['username']=$map['admin_name'];
            redirect('../users/userlist');
        }
    }
 


    public function check_verify($code, $id = ''){
        $verify = new \Think\Verify();
        return $verify->check($code, $id);
    }


    public function _initialize(){
        //只要不是显示登录页面和处理登录、验证码这些，其他情况都要进行session验证。
           header("Content-type:text/html;charset=utf-8");
       if(ACTION_NAME!='index' && ACTION_NAME!='checkLogin'&& ACTION_NAME!='verify') {
         
            if(null==session('flag')|| session('flag')!='logok'){
                redirect('index');
            }
        }
    }
public function verify(){
        ob_clean;
        $Verify =new \Think\Verify();
        $Verify->entry();

     }

}